<template>
  <super-table
    :pageSize="50"
    :pagination=pagination
    :scroll="{ x: 1100}"
    ref="ref_triage_table"
    ls_props_columns="triage"
    :rowKey="(record,index)=> index"
    :columns="triageColumns"
    :data="loadTriageData"
  >
    <!--序号-->
    <template slot="index" slot-scope="text,record,index">
      <span>{{index+1}}</span>
    </template>
    <!--项目名称-->
    <template slot="receiveItemName" slot-scope="text">
      <a-tooltip placement="bottomLeft">
        <template slot="title">
          {{text}}
        </template>
        {{text}}
      </a-tooltip>
    </template>

  </super-table>

</template>

<script>
import {SuperTable} from '@/components'
import { getTriageById } from '@/api/customer/customer'

export default {
  name: 'TabTriageRecord',
  components:{
    SuperTable
  },
  props:{
    customerId:{
      type:String,
      default:''
    },
  },

  data(){
    return{
      //封装的超级表格数据，需要返回一个promise，可见src/components/table组件
      loadTriageData: parameter => {
        return getTriageById(this.customerId).then(res => {
          console.log('分诊记录',res)
          return res
        })
      },

      triageColumns: [
        { title: '序号',scopedSlots: { customRender: 'index' }, width:60,fixed:'left'},
        { title: '咨询项目', dataIndex: 'receiveItemName', width: 150, scopedSlots: { customRender: 'receiveItemName' },ellipsis: true },
        { title: '分诊时间', dataIndex: 'triage_date', width: 120 },
        { title: '开发人', dataIndex: 'developerid', width: 120 },
        { title: '所属咨询', dataIndex: 'consultMan', width: 120 },
        { title: '就诊状态', dataIndex: 'admission_state', width: 120 },
        { title: '咨询状态', dataIndex: 'consult_state', width: 120 },
        { title: '登记人', dataIndex: 'receiveMan', width: 120 },
        { title: '取消原因', dataIndex: 'cancel_reason', width: 150 },
      ],
      pagination: {
        pageSizeOptions: ['50', '100', '150','200'], //这里注意只能是字符串，不能是数字
      },
    }
  },

   watch:{
      $route(){ 
          if(this.$route.query.id && this.$route.query.card_no){
              this.customerId = this.$route.query.id
              this.card_no = this.$route.query.card_no
              this.$refs.ref_triage_table && this.$refs.ref_triage_table.refresh()
          }     
      },
  },

  activated() {
    if(this.$store.state.app.multiTab){
      // console.log('这里是激活缓存',this.$store.state.app)
      this.$nextTick(()=>{
        this.$refs.ref_triage_table && this.$refs.ref_triage_table.refresh()
      })
    }
  },
}
</script>

<style scoped>

</style>